package chapter07

import scala.collection.mutable

/**
 *
 * @author cdhuangchao3
 * @date 2023/6/10 3:35 PM
 */
object Test07_MutableSet {
  def main(args: Array[String]): Unit = {
    // 1.创建set
    val set1 = mutable.Set(1, 2, 3, 4, 6)
    println(set1)

    // 2.添加元素
    val set2 = set1 + 11
    println(set1)
    println(set2)

    set1 += 12
    println(set1)

    set1.add(19)
    println(set1)
    println("="*20)

    // 3.删除元素
    set1 -= 2
    println(set1)

    val flag1 = set1.remove(19)
    println(flag1)

    // 4.合并set
    val set3 = mutable.Set(9,5, 3, 4, 6)

    println("="*20)
    val set4 = set1 ++ set3
    println(set4)

    set1 ++= set3
    println(set1)
  }
}
